package com.gitee.feizns.explore.data_structure.recursive;

/**
 * @author feizns
 * @since 2019/11/11
 */
public class Sum {

    public static void main(String[] args) {
        System.out.println(sum(new int[]{1, 2, 3, 4, 5}));
    }

    public static int sum(int[] sum) {
        return sum(sum, 0);
    }

    private static int sum(int[] sum, int start) {
        return start == sum.length ? 0 : sum[start] + sum(sum, start + 1);
    }

}
